package com.itany.corejava.day16;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class TestServerB {

    public static void main(String[] args) {

        System.out.println("服务器");


        try(ServerSocket ss=new ServerSocket(8888)){

            while(true){

                try(Socket s=ss.accept();
                    BufferedReader br=new BufferedReader(
                            new InputStreamReader(
                                s.getInputStream()
                            )
                    );
                    PrintWriter pw=new PrintWriter(
                            s.getOutputStream()
                    )){



                    String name=br.readLine();


                    if("abc".equals(name)){
                        Thread.sleep(99999);
                    }


                    pw.println("Hello "+name+"!");

                    pw.flush();


                }catch (Exception e){
                    throw e;
                }



            }


        }catch (Exception e){
            e.printStackTrace();
        }


    }




}
